package buttons;

import controllers.ButtonControl;
import utils.ItemColorChange;

import javax.swing.*;
import java.awt.image.BufferedImage;

/**
 * @version V1.0
 * @Title: 通用button，重写了构造方法
 * @Package
 * @Description:
 * @author: GaleBlade
 * @date:
 */
public class CommonButton extends JButton {

    public ButtonControl mouse;

    public CommonButton(BufferedImage img, int x, int y, int width, int height){
        super.setContentAreaFilled(false);
        super.setIcon(new ImageIcon(ItemColorChange.change(img)));
        super.setBorder(null);
        super.setBounds(x,y,width,height);
        //添加鼠标事件
        mouse = new ButtonControl(this,img);
        super.addMouseListener(mouse);
    }

    public void removeListener(){
        super.removeMouseListener(mouse);
    }

}
